#pragma once
#include <map>
#include "afn04types.h"

#define Afn04fx_Fx(AP,x) AP##Afn04f##x& F##x(uint16_t)

#define AFN04_PARSER_DEFINITION(AP) \
class AP##Afn04Parser\
{\
public:\
	typedef AP##Afn04Types Union;\
	typedef map<uint8_t,map<uint16_t,Union>> UnionMap;\
	typedef int(AP##Afn04Parser::*Callback)(uint8_t*);\
	UnionMap umap;\
protected:\
	Callback call[256];\
public:\
	AP##Afn04Parser(void);\
public:\
	void clear(void);\
	bool append(Buffer&);\
	Afn04fx_Fx(AP,65);\
	Afn04fx_Fx(AP,66);\
	Afn04fx_Fx(AP,67);\
	Afn04fx_Fx(AP,68);\
public:\
	int parse(uint8_t *data, int len);\
	int parseF65(uint8_t*);\
	int parseF66(uint8_t*);\
	int parseF67(uint8_t*);\
	int parseF68(uint8_t*);\
};

#pragma pack(1)
AFN04_PARSER_DEFINITION(Active)
AFN04_PARSER_DEFINITION(Pasive)
#pragma pack(0)

class Afn04Parser
{
	ActiveAfn04Parser active;
	PasiveAfn04Parser pasive;
public:
	Afn04Parser(void);
};
